package com.scienview.test;

import java.io.IOException;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import org.codehaus.jackson.JsonParseException;
import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.map.JsonMappingException;
import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.type.TypeReference;

import com.scienview.core.util.JackJson;

public class Classes implements Serializable{

	private String name;
	  List<Tearch> tearcherList=new ArrayList<Tearch>();;
	
	 
	@org.junit.Test
	public void test(){
		Classes classes=new Classes();
		Courses courses=new Courses();
		courses.name="courses";
		Student s=new Student();
		s.coursesList.add(courses);
		s.name="student";
		Tearch t=new Tearch();
		t.name="tearcher";
		t.studnetList.add(s);
		classes.tearcherList.add(t);
		
		String ss=JackJson.fromObjectToJson(classes);
		System.out.println(ss);
		Classes c=JackJson.fromJsonToObject(ss, Classes.class);
		System.out.println(c);
		
		String tt=JackJson.fromObjectToJson(classes.tearcherList);
		System.out.println(tt);
		//List<Tearch> list=JackJson.fromJsonToList(tt, new TypeReference<List<Tearch>>(){});
		List<Tearch> list=JackJson.fromJsonToList(tt, JackJsonConstants.getTypeReference());
		//List<Tearch> list=(List<Tearch>) JackJson.fromJsonToList(tt, Tearch.class);
		//由于不存在 实现类 实现类型的转化 得不到真实的类型 
		System.out.println(list);
	}
	
	@org.junit.Test
	public void test2(){
		String ss="{\"tearcherList\":[{\"name\":\"tearcher\",\"studnetList\":[{\"name\":\"student\"}]}]}";
		Classes c=JackJson.fromJsonToObject(ss, Classes.class);
		System.out.println(c);
	}
	public List<Tearch> getTearcherList() {
		return tearcherList;
	}

	public void setTearcherList(List<Tearch> tearcherList) {
		this.tearcherList = tearcherList;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}	
	
}
